<template>
  <div class="wrap">
    <img src="../assets/loginBg.png" class="bg" alt />
    <div class="center">
      <img src="../assets/loginLogo.png" class="loginLogo" alt srcset />
      <h3>欢迎使用捷报订单管理系统</h3>
      <div class="form">
        <div class="item">
          <img src="../assets/loginPhone.png" alt />
          <input type="text" v-model="account" placeholder="请输入用户名" />
        </div>
        <div class="item">
          <img src="../assets/pass.png" alt />
          <input type="passwrod" v-model="password" placeholder="请输入密码" />
        </div>
        <div class="bok">
          <p @click="login">登陆</p>
          <p @click="register">注册</p>
        </div>
      </div>
    </div>
  </div>
</template>
<style scoped lang="scss">
.wrap {
  height: 100vh;
  position: relative;
  min-width: 1300px;
  min-height: 720px;
  margin: 0 auto;
  .bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    min-height: 720px;
  }
  .center {
    position: absolute;
    left: 50%;
    top: 10%;
    width: 44%;
    height: 580px;
    .loginLogo {
      width: 60px;
      margin-left: 100px;
      margin-top: 60px;
    }
    h3 {
      color: #719bef;
      font-size: 30px;
      margin-left: 100px;
      margin-top: 10px;
    }
    .form {
      margin-top: 80px;
      margin-left: 100px;
      .item {
        height: 60px;
        display: flex;
        align-items: center;
        border-bottom: 0.5px solid #719bef;
        width: 300px;
        margin-top: 20px;
        ::-webkit-input-placeholder {
          color: #719bef;
        }
        input {
          outline: none;
          background: transparent;
          border: none;
          display: block;
          margin-left: 15px;
          height: 100%;
          color: #719bef;
          font-size: 16px;
        }
        img {
          width: 20px;
        }
      }
      .bok {
        display: flex;
        align-items: center;
        margin-top: 50px;
        justify-content: space-between;
        width: 300px;
        p {
          width: 100px;
          height: 30px;
          border-radius: 30px;
          background: #719bef;
          text-align: center;
          line-height: 30px;
          color: #fff;
          cursor: pointer;
        }
        p:nth-of-type(2) {
          color: #719bef;
          border: 1px solid #719bef;
          background: #fff;
        }
      }
    }
  }
}
</style>

<script>
import { login } from "@/utils/interface";
export default {
  data() {
    return {
      account: "",
      password: ""
    };
  },
  methods: {
    login() {
      if (!this.account) {
        this.$alert("请输入用户名", "提示", {
          confirmButtonText: "确定",
        });
        return false
      }
      if (!this.password) {
        this.$alert("请输入密码", "提示", {
          confirmButtonText: "确定",
        });
        return false
      }
      login({account:this.account,password:this.password}).then(res=>{
          if(res.data.code == 200){
            localStorage.setItem('admin',res.data.data.jsessionid)
              this.$router.push('/')
          }
      })
    },
    register(){
      this.$router.push('/register')
    }
  }
};
</script>

